﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QxFramework.Core;
//[RequireComponent(typeof(Item))]
public abstract class ItemFunc : MonoBehaviour//, IItemFunc
{
    public string Name = "这里是技能名字";
    public string Abstract = "这里是技能描述";

    public Sprite FuncIconSetting;

    /// <summary>
    /// 此技能附属的物体
    /// </summary>
    public CombinableItem ThisItem;
    public virtual void Awake()
    {
        ThisItem = this.GetComponent<CombinableItem>();
    }
    public virtual void OnStart() { }
    //    public virtual string FuncAbstract => Abstract;

    //public virtual string FuncName => Name;
    [HideInInspector]
    public KeyCode key;
    public virtual KeyCode Key { get =>key; }

    ///public KeyState KeyState => KeyState.On;

    public virtual Sprite FuncIcon
    {
        get => FuncIconSetting;
        set => FuncIconSetting=value;
    }
    public virtual void InvokeByEnmey()
    {
        
    }
    public virtual void KeyDownInvoke()
    {

    }
    public virtual void KeyOnInvoke()
    {

    }

    public virtual void KeyUpInvoke()
    {

    }

    public void InitFuncField(FuncField field)
    {
        //    throw new NotImplementedException();
        Debug.Assert(field.FuncTypeName == this.GetType().ToString());
        Debug.Assert(this.gameObject.name == field.BelongingItemName);
        key = field.Key;
    }
    public virtual void OnDestory() { }
    public virtual void KeyDownPreference() { }

    public virtual void KeyOnPreference() { }

    public virtual void KeyUpPreference() { }
}
[Serializable]
public class FuncField
{
    public string BelongingItemName;
    public string FuncTypeName;
    public KeyCode Key;
}
/*public interface IItemFunc
{
    void KeyDownInvoke();

    void KeyOnInvoke();

    void KeyUpInvoke();
    void KeyDownPreference();

    void KeyOnPreference();

    void KeyUpPreference();
    string FuncAbstract { get; }
    string FuncName { get; }
    Sprite FuncIcon { get; }
    KeyCode Key { get; }
  //  KeyState KeyState { get; }
    void InitFuncField(FuncField field);
}*/
public enum KeyState
{
    On,
    Up,
    Down
}
